package com.qinggeng.project.api.controller;

import com.qinggeng.common.enums.ShowTypeEnum;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.project.api.security.annotation.LoginRequired;
import com.qinggeng.project.api.security.utils.ApiUtils;
import com.qinggeng.project.system.domain.vo.RedEnvelopesActivityVO;
import com.qinggeng.project.system.domain.vo.RedEnvelopesSumMoneyVO;
import com.qinggeng.project.system.service.IUserActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("${apiPath}/activity")
public class ApiActivityRedEnvelopesController extends BaseController {

    @Autowired
    private IUserActivityService userActivityService;

    @GetMapping("/redEnvelopes")
    public AjaxResult redEnvelopes(@RequestHeader(name = "token",required = false) String token) {
        RedEnvelopesActivityVO envelopesActivityVO = userActivityService.checkRedEnvelopes(token);
        return AjaxResult.success(envelopesActivityVO);
    }


    @LoginRequired(role = ApiUtils.DEFAULT_ROLE_USER)
    @GetMapping("/grabredEnvelopes")
    public AjaxResult grabredEnvelopes() {
        Long userId=ApiUtils.getUserId();
        RedEnvelopesSumMoneyVO redEnvelopesSumMoneyVO=userActivityService.grabredRedEnvelopesSumMoneyVO(userId);
        return AjaxResult.success(null,ShowTypeEnum.后台.getValue(),redEnvelopesSumMoneyVO);
    }

}
